//
//  CertificateHeaderView.m
//  VideoExam
//
//  Created by apple on 2020/4/17.
//

#import "CertificateHeaderView.h"
@interface CertificateHeaderView ()
@property(nonatomic,strong)UIView * baseView;
@property(nonatomic,strong)UILabel * showTitleLabel;
@property(nonatomic,strong)QMUILabel * typeLabel;
@property(nonatomic,strong)UILabel * timeLabel;
@property(nonatomic,strong)UIImageView * certificateImageView;
@property(nonatomic,assign)CGFloat cellHeight;
@property(nonatomic,strong)UIImageView * angle_imageView;

@property(nonatomic,strong)UILabel * headerTitleLabel;
@end
@implementation CertificateHeaderView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self uiSet];
    }
    return self;
}
- (void)uiSet {
      self.baseView = [[UIView alloc] initWithFrame:CGRectMake(20, 10, SCREEN_WIDTH -40, (SCREEN_WIDTH -40)*0.59)];
      self.baseView.backgroundColor=[UIColor whiteColor];
      self.baseView.layer.cornerRadius=12;
      self.baseView.layer.masksToBounds=YES;
      [self addSubview:self.baseView];
      
      
      self.certificateImageView =[UIFactory create_ImageView_ImageName:@""];
     self.certificateImageView.backgroundColor = color(@"#F0F0F0");
      [self.baseView addSubview:self.certificateImageView];
      [self.certificateImageView mas_makeConstraints:^(MASConstraintMaker *make) {
          make.edges.mas_equalTo(self.baseView);
      }];
    
      self.angle_imageView =[UIFactory create_ImageView_ImageName:@"证书角标"];
     [self.baseView addSubview:self.angle_imageView];
     [self.angle_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.right.mas_equalTo(self.baseView);
         make.top.mas_equalTo(0);
         make.size.mas_equalTo(CGSizeMake(78, 78));
     }];
    
    self.typeLabel = [UIFactory create_LabelContent:@"钢琴" textColor:[UIColor whiteColor] fontSize:12];
    self.typeLabel.textAlignment = NSTextAlignmentCenter;
    self.typeLabel.frame = CGRectMake(10, -10, 78, 78);
    [self.angle_imageView addSubview:self.typeLabel];
    self.typeLabel.transform = CGAffineTransformMakeRotation(M_PI_4-0.03);

    UIView * bottomView = [[UIView alloc] initWithFrame:CGRectZero];
    bottomView.backgroundColor = RGBA(0, 0, 0, 0.4);
    [self.baseView addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.baseView);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(30);
    }];
    
    
     self.showTitleLabel = [UIFactory create_LabelContent:@"中国音乐考级协会" textColor:[UIColor whiteColor] fontSize:12];
      [bottomView addSubview:self.showTitleLabel];
      [self.showTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
          make.top.mas_equalTo(0);
          make.left.mas_equalTo(12);
          make.height.mas_equalTo(bottomView);
      }];
    
      
    self.timeLabel = [UIFactory create_LabelContent:@"2020-03-20 12:20" textColor:[UIColor whiteColor] fontSize:12];
    self.timeLabel.textAlignment=NSTextAlignmentRight;
    [bottomView addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.mas_equalTo(0);
         make.right.mas_equalTo(bottomView.mas_right).offset(-12);
         make.height.mas_equalTo(bottomView);
    }];
      
    
    self.headerTitleLabel = [UIFactory create_LabelContent:@"实物证书邮寄地址" textColor:nil fontSize:13];
    self.headerTitleLabel.font = [UIFont boldSystemFontOfSize:13];
    [self addSubview:self.headerTitleLabel];
    [self.headerTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.baseView.mas_bottom).offset(20);
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(self.mas_right).offset(-20);
        make.height.mas_equalTo(20);
    }];
    [self layoutIfNeeded];
    self.height = self.headerTitleLabel.bottom+10;
   
}
- (void)setModel:(OrderDetailsModel *)model {
    _model = model;
    [self.certificateImageView sd_setImageWithURL:[NSURL URLWithString:_model.certificateUrl] placeholderImage:UIImageMake(@"大占位图")];
    self.showTitleLabel.text = _model.committeeName;
    self.timeLabel.text = _model.orderCreateDate;
    
}
@end
